package com.jws.jawestshow.config;

import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import com.jws.jawestshow.R;
import com.jws.jawestshow.NFCActivity;
import com.jws.jawestshow.CameraActivity;
import com.jws.jawestshow.LEDActivity;
import com.jws.jawestshow.WiegandActivity;
import com.jws.jawestshow.RelayActivity;
import com.jws.jawestshow.InfraredActivity;
import com.jws.jawestshow.Rs485Activity;
import com.jws.jawestshow.LedLightActivity;
import com.jws.jawestshow.IDCardReaderActivity;
import com.jws.jawestshow.WriteWiegandActivity;


public class ItemConfig {
	
	public static Map<String,Class<?>> keyclassmap; 
	public static Map<String,Integer>  keystringmap;
	public static Map<String,Integer>  keyimgidmap;
	public static Map<String,Integer>  keyIndexmap;
	 
	public ItemConfig()
	{
		keyclassmap = new HashMap<String, Class<?>>();
		keyclassmap.put(Properties.KEY_NFC, NFCActivity.class);
		keyclassmap.put(Properties.KEY_LED, LEDActivity.class);
		keyclassmap.put(Properties.KEY_WIEGAND, WiegandActivity.class);
		keyclassmap.put(Properties.KEY_CAMERA, CameraActivity.class);
		keyclassmap.put(Properties.KEY_RELAY, RelayActivity.class);
		keyclassmap.put(Properties.KEY_INFRARED, InfraredActivity.class);
		keyclassmap.put(Properties.KEY_RS480, Rs485Activity.class);
		keyclassmap.put(Properties.KEY_LEDLIGHT, LedLightActivity.class);
		keyclassmap.put(Properties.KEY_IDCARDREADER, IDCardReaderActivity.class);
		keyclassmap.put(Properties.KEY_WRITEWIEGAND, WriteWiegandActivity.class);
		
		
		keystringmap=new HashMap<String, Integer>();
		keystringmap.put(Properties.KEY_NFC, R.string.jws_nfc);	
		keystringmap.put(Properties.KEY_LED, R.string.jws_led);
		keystringmap.put(Properties.KEY_WIEGAND, R.string.jws_wiegand);
		keystringmap.put(Properties.KEY_CAMERA, R.string.jws_camera);
		keystringmap.put(Properties.KEY_RELAY, R.string.jws_relay);
		keystringmap.put(Properties.KEY_INFRARED, R.string.jws_infrared);
		keystringmap.put(Properties.KEY_RS480, R.string.jws_rs485);
		keystringmap.put(Properties.KEY_LEDLIGHT, R.string.jws_led_light);
		keystringmap.put(Properties.KEY_IDCARDREADER, R.string.jws_idcardreader);
		keystringmap.put(Properties.KEY_WRITEWIEGAND, R.string.jws_writewiegand);
		
		keyimgidmap=new HashMap<String, Integer>();
		keyimgidmap.put(Properties.KEY_NFC, R.drawable.background01);	
		keyimgidmap.put(Properties.KEY_LED, R.drawable.background02);
		keyimgidmap.put(Properties.KEY_WIEGAND, R.drawable.background03);
		keyimgidmap.put(Properties.KEY_CAMERA, R.drawable.background04);
		keyimgidmap.put(Properties.KEY_RELAY, R.drawable.background05);
		keyimgidmap.put(Properties.KEY_INFRARED, R.drawable.background06);
		keyimgidmap.put(Properties.KEY_RS480, R.drawable.background07);
		keyimgidmap.put(Properties.KEY_LEDLIGHT, R.drawable.background08);
		keyimgidmap.put(Properties.KEY_IDCARDREADER, R.drawable.background09);
		keyimgidmap.put(Properties.KEY_WRITEWIEGAND, R.drawable.background10);
		
		
		keyIndexmap=new HashMap<String, Integer>();
		keyIndexmap.put(Properties.KEY_NFC, 0);
		keyIndexmap.put(Properties.KEY_LED, 1);
		keyIndexmap.put(Properties.KEY_WIEGAND, 2);
		keyIndexmap.put(Properties.KEY_CAMERA, 3);
		keyIndexmap.put(Properties.KEY_RELAY, 4);
		keyIndexmap.put(Properties.KEY_INFRARED, 5);
		keyIndexmap.put(Properties.KEY_RS480, 6);
		keyIndexmap.put(Properties.KEY_LEDLIGHT, 7);
		keyIndexmap.put(Properties.KEY_IDCARDREADER, 8);
		keyIndexmap.put(Properties.KEY_WRITEWIEGAND, 9);
		
	}
	
	
	public static String[] AllItems = 
	{  
			Properties.KEY_NFC,
			Properties.KEY_LED, 
			Properties.KEY_WIEGAND, 
			Properties.KEY_WRITEWIEGAND,      
			Properties.KEY_RELAY,
			Properties.KEY_INFRARED, 
			Properties.KEY_CAMERA,  
			Properties.KEY_RS480, 
			Properties.KEY_LEDLIGHT,
			Properties.KEY_IDCARDREADER, 
	};

	public static int getKeyIndex(String keyToCheck){
		Iterator<String> keys = keyIndexmap.keySet().iterator();
		while(keys.hasNext()){
			String key = (String)keys.next();
			if(keyToCheck.equals(key)){
				return keyIndexmap.get(keyToCheck); 
			}
		}
		return -1;
	}

	public static int getKeyStringID(String keyToCheck){
		Iterator<String> keys = keystringmap.keySet().iterator();
		while(keys.hasNext())
		{
			String key = (String)keys.next();
			if(keyToCheck.equals(key)){
				return keystringmap.get(keyToCheck); 
			}
		}
		return -1;
	}
		
	public static int getKeyimageID(String keyToCheck){
		Iterator<String> keys = keyimgidmap.keySet().iterator();
		while(keys.hasNext())
		{
			String key = (String)keys.next();
			if(keyToCheck.equals(key)){
				return keyimgidmap.get(keyToCheck); 
			}
		}
		return -1;
	}
		
	public static Class<?> getMapClass(String key)
	{
		return keyclassmap.containsKey(key)?keyclassmap.get(key):null;
	}
		
	public  List<String> getArea1LinkedList(String[] str)
	{
		LinkedList<String> Area1list=new LinkedList<String>();
		for (int i = 0; i < str.length; i++) {
			Area1list.add(str[i]);
		}
		return Area1list; 
	}
}
